/** 
 *  @file       dot_martix.c
 *  @brief      点阵驱动程序
 *  @author     Z B T   
 *  @version    V0.1
 *  @date       2015-10
 */
 
#include "dot_martix.h"
#include "74HC595.h"
#include "delay.h"
#include "config.h"


/**
 *  点阵扫描函数
 *  @param None
 *  @return None
 */
void dot_martix_scan(void)
{
    unsigned char i;
    unsigned char row_value;
    
    hc595_send_4bit_data(0x00, 0x00, 0xff, 0xff);       /**< 全亮 */
    delay_ms(200);
    /** 行扫描 */
    row_value = 0x01;
    for (i = 0; i < 8; i++)
    {
        hc595_send_4bit_data(0x00, 0x00, 0x00, row_value);
        row_value <<= 1;
        delay_ms(100);
    }
    row_value = 0x01;
    for (i = 0; i < 8; i++)
    {
        hc595_send_4bit_data(0x00, 0x00, row_value, 0x00);
        row_value <<= 1;
        delay_ms(100);
    }
    /** 列扫描 */
    row_value = 0x01;
    for (i = 0; i < 8; i++)
    {
        hc595_send_4bit_data(0xff, ~row_value, 0xff, 0xff);
        row_value <<= 1;
        delay_ms(100);
    }
    row_value = 0x01;
    for (i = 0; i < 8; i++)
    {
        hc595_send_4bit_data(~row_value, 0xff, 0xff, 0xff);
        row_value <<= 1;
        delay_ms(100);
    }
}